package easy;

import java.util.ArrayList;
import java.util.List;

public class Solution_1790 {

    public boolean areAlmostEqual(String s1, String s2) {
        List<Integer> set = new ArrayList<>();
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) != s2.charAt(i)) {
                set.add(i);
            }
            if (set.size() > 2) {
                return false;
            }
        }
        return set.size() == 0 || (set.size() == 2 && s1.charAt(set.get(1)) == s2.charAt(set.get(0))
            && s1.charAt(set.get(0)) == s2
            .charAt(set.get(1)));
    }
}
